import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据加载中...

export const columns: BasicColumn[] = [
  //  {
  //   title: '门店编码',
  //   align:"center",
  //   dataIndex: 'storeCode'
  //  },
   {
    title: '门店名称',
    align:"center",
    dataIndex: 'storeName'
   },
   {
    title: '商品条码',
    align:"center",
    dataIndex: 'goodsNo'
   },
   {
    title: '商品名称',
    align:"center",
    dataIndex: 'goodsName'
   },
  //  {
  //   title: '商品编码',
  //   align:"center",
  //   dataIndex: 'goodsCode'
  //  },
   {
    title: '销售日期',
    align:"center",
    dataIndex: 'createdDate',
    sorter: true,
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '销售数量',
    align:"center",
    dataIndex: 'saleNumber'
   },
   {
    title: '销售金额',
    align:"center",
    dataIndex: 'saleAmount'
   },
   {
    title: '业务员',
    align:"center",
    dataIndex: 'salesUser'
   },
   {
    title: '代理商',
    align:"center",
    dataIndex: 'agent'
   },
   {
    title: '系统',
    align: "center",
    dataIndex: 'channal'
  },
  {
    title: '省',
    align: "center",
    dataIndex: 'province'
  },
  {
    title: '市',
    align: "center",
    dataIndex: 'city'
  },
  {
    title: '区',
    align: "center",
    dataIndex: 'district'
  },

];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "门店名称",
      field: "storeName",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "商品条码",
      field: 'goodsNo',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "商品名称",
      field: 'goodsName',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "销售日期",
      field: "saleDate",
      component: 'RangePicker',
      componentProps: {
        valueType: 'Date',
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '门店id',
    field: 'storeId',
    component: 'Input',
  },
  {
    label: '门店编码',
    field: 'storeCode',
    component: 'Input',
  },
  {
    label: '门店名称',
    field: 'storeName',
    component: 'Input',
  },
  {
    label: '商品条码',
    field: 'goodsNo',
    component: 'Input',
  },
  {
    label: '商品名称',
    field: 'goodsName',
    component: 'Input',
  },
  {
    label: '商品编码',
    field: 'goodsCode',
    component: 'Input',
  },
  {
    label: '销售日期',
    field: 'saleDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '销售数量',
    field: 'saleNumber',
    component: 'Input',
  },
  {
    label: '销售金额',
    field: 'saleAmount',
    component: 'Input',
  },
  {
    label: '业务员',
    field: 'salesman',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  storeId: {title: '门店id',order: 0,view: 'text', type: 'string',},
  storeCode: {title: '门店编码',order: 1,view: 'text', type: 'string',},
  storeName: {title: '门店名称',order: 2,view: 'text', type: 'string',},
  goodsNo: {title: '商品条码',order: 3,view: 'text', type: 'string',},
  goodsName: {title: '商品名称',order: 4,view: 'text', type: 'string',},
  goodsCode: {title: '商品编码',order: 5,view: 'text', type: 'string',},
  saleDate: {title: '销售日期',order: 6,view: 'date', type: 'string',},
  saleNumber: {title: '销售数量',order: 7,view: 'text', type: 'string',},
  saleAmount: {title: '销售金额',order: 8,view: 'text', type: 'string',},
  salesman: {title: '业务员',order: 9,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}